package org.example.exception;


import lombok.Getter;
import lombok.Setter;

@Getter
@Setter

public class AppException extends RuntimeException{
    //抛异常的时候是throw new AppException("USR001","用户账号或密码错误")
    //就需要有一个code字段来保存这个信息
    private String code;

    //我们这里
    public AppException(String code,String message) {
        super(message);
        this.code = code;
    }

    //类似之前写JDBC代码，try{...} catch{SQLException e}{ throw new RuntimeException("用户登录JDBC操作出错"，e)
    //一个异常，构造方法传入捕获的异常对象，就可以携带捕获的异常堆栈信息
    public AppException(String code,String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
}
